package commons

import (
	"go.uber.org/zap"
	"sync"
)

/*
简单封装zap Logger
*/

// 包级别变量日志器
var logger *zap.Logger

// 确保初始化一次
var once sync.Once

func GetLogger() *zap.Logger {
	once.Do(func() {
		config := zap.Config{
			Encoding:         "json",
			Level:            zap.NewAtomicLevelAt(zap.DebugLevel),
			OutputPaths:      []string{"stdout", "./out.log"},
			ErrorOutputPaths: []string{"stderr"},
		}
		logger1, _ := config.Build()
		logger = logger1
	})
	return logger
}
